package sugarbind_input

import java.util.HashSet;

class Lectin {

	String lectin_Name='Unknown'
	String gene_Name
	String cermav_Ref
	
    static constraints = {
		lectin_Name(nullable:false)
		gene_Name(nullable:true)
		cermav_Ref(nullable:true)
		
//		lectin_Support(unique:['lectin_Name'])
    }
	
	static hasMany = [ bindings:Binding, lectin_Uniprots:Lectin_Uniprot]
	static hasOne = [lectin_Support:Lectin_Support]
	
	static mapping = {
//			id column: 'lectin_id'
			id generator: 'sequence', params: [sequence: 'lectin_id_seq']
		}
		
	public String toString(){
		HashSet<Ligand> ligands = new HashSet<Ligand>()
			for(binding in bindings)
			{
//				if(binding!=null)
//				{ 
					ligands.add(binding.ligand.structure)
//				}
			}
		
			lectin_Name + " (" + id + ") " + " agent : " +lectin_Support.agent.agent_Name + ", support : " + lectin_Support.lectin_Support_Type.lectin_Support_Type_Name + " " + lectin_Support.lectin_Support_Name//ligands//+ binding.ligand.full_Name
		}
	
	public static listLectins()
	{
		Lectin.list().sort{ it.toString(); }
	}
}
